home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
BUS
/
TMCM Software and Labs.sit
/
Software for TMCM 7_95
/
Files for Lab 11
/
Trees
< prev
Wrap
Text File
|
1993-10-31
|
1KB
|
60 lines
SUB Tree(size, complexity)
{ This subroutine (from Figure 7.8 of "The Most
Complex Machine") draws a recursive tree. Its
height is given, approximately, by the parameter
size; the number of levels of branching is given
by the parameter complexity. The tree has its
"root" at the current turtle position; after the
tree is drawn, the turtle is left at its original
position and heading. }
IF complexity = 0 THEN
forward(size)
back(size)
ELSE
forward(size/2)
turn(45)
Tree(size/2, complexity - 1)
turn(-90)
Tree(size/2, complexity - 1)
turn(45)
back(size/2)
END IF
END SUB
SUB TestTree
{ This subroutine can be called to draw sample trees;
the user is asked to specify the complexity and a
tree of that complexity is drawn filling most of the
screen. }
DECLARE complexity
penUp
MoveTo(0,-9)
penDown
face(90)
clear
AskUser("What level of complexity do you want (0 to 12)?", complexity)
complexity := trunc(complexity) { Make sure value is OK }
IF complexity < 0 THEN
complexity := 0
TellUser("Using complexity = 0.")
END IF
IF complexity > 12 THEN
complexity := 12
TellUser("Using complexity = 12.")
END IF
Tree(18,complexity)
END SUB